package cn.wolfcode.controller;


import cn.wolfcode.entity.*;
import cn.wolfcode.service.*;
import cn.wolfcode.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author c1eye
 * @since 2022-11-03
 */
@RestController
@CrossOrigin
@RequestMapping("/destinations")
public class DestinationController {
    @Autowired
    private IRegionService regionService;

    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @GetMapping("/hotRegion")
    public JSONResult hotRegion() {
        List<Region> list = regionService.hotRegion();
        return JSONResult.success(list);
    }

    @GetMapping("/search")
    public JSONResult search(int regionId) {
        List<Destination> list = destinationService.search(regionId);
        return JSONResult.success(list);
    }

    @GetMapping("/toasts")
    public JSONResult toasts(@RequestParam("destId") Long id) {
        List<Destination> list =  destinationService.queryToasts(id);
        return JSONResult.success(list);
    }

    @GetMapping("/catalogs")
    public JSONResult catalogs(int destId){
        List<StrategyCatalog> list = strategyCatalogService.queryByDestId(destId);
        return JSONResult.success(list);
    }

    @GetMapping("/strategies/viewnumTop3")
    public JSONResult strategies_viewnumTop3(int destId){
        List<Strategy> list = strategyService.getTop3(destId);
        return JSONResult.success(list);
    }

    @GetMapping("/list")
    public JSONResult list(){
        List<Destination> list = destinationService.list();
        return JSONResult.success(list);
    }
    @Autowired
    private ITravelService travelService;
    @GetMapping("/travels/viewnumTop3")
    public JSONResult queryViewNumTop3(Long destId) {
        List<Travel> list = travelService.queryViewNumTop3(destId);
        return JSONResult.success(list);
    }
}

